pull: Properly clean up after test
authorColin Walters <walters@verbum.org>
Tue, 1 Nov 2011 16:35:50 +0000 (12:35 -0400)
committerColin Walters <walters@verbum.org>
Tue, 1 Nov 2011 16:35:50 +0000 (12:35 -0400)
tests/libtest.sh
tests/run-apache.c
tests/tmpdir-lifecycle.c

index 5c0dff85fff9aab7e8c2e9ad0ed2469b196de469..526c88aa56b10e1c74dc2d95b8a4c993314a6d27 100644 (file)
@@ -139,7 +139,18 @@ StartServers 1
 Alias /ostree/ ${test_tmpdir}/ostree-srv/
 # ScriptAlias /ostree/  ${test_tmpdir}/httpd/ostree-http-backend/
 EOF
-    ${SRCDIR}/tmpdir-lifecycle ${SRCDIR}/run-apache `pwd`/httpd.conf ${test_tmpdir}/httpd-address
+    ${SRCDIR}/tmpdir-lifecycle ${SRCDIR}/run-apache `pwd`/httpd.conf ${test_tmpdir}/httpd-address &
+    for i in $(seq 5); do
+       if ! test -f ${test_tmpdir}/httpd-address; then
+           sleep 1
+       else
+           break
+       fi
+    done
+    if ! test -f ${test_tmpdir}/httpd-address; then
+       echo "Error: timed out waiting for httpd-address file"
+       exit 1
+    fi
     cd ${oldpwd} 
 }
 
index b5f7e5c7fa67899f10d064a451dc746dc82242cb..b074e6e7902d6b8ff6b22237e82a3c454a2c6e72 100644 (file)
@@ -134,6 +134,7 @@ main (int     argc,
 
   httpd_argv = g_ptr_array_new ();
   g_ptr_array_add (httpd_argv, "httpd");
+  g_ptr_array_add (httpd_argv, "-X");
   g_ptr_array_add (httpd_argv, "-f");
   g_ptr_array_add (httpd_argv, argv[1]);
   g_ptr_array_add (httpd_argv, "-C");
index 95aae633818f1aa9adb14d303f87b9a864e5577b..fac0c48a5b08bb5cd9598b62f375d384f8477013 100644 (file)
@@ -65,7 +65,6 @@ main (int     argc,
   GError *error = NULL;
   GPtrArray *new_argv;
   int i;
-  GPid pid;
   struct TmpdirLifecyleData data;
 
   g_type_init ();
@@ -87,12 +86,12 @@ main (int     argc,
   g_ptr_array_add (new_argv, NULL);
 
   if (!g_spawn_async (NULL, (char**)new_argv->pdata, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
-                      NULL, NULL, &pid, &error))
+                      NULL, NULL, &data.pid, &error))
     {
       g_printerr ("%s\n", error->message);
       return 1;
     }
-  g_child_watch_add (pid, on_child_exited, &data);
+  g_child_watch_add (data.pid, on_child_exited, &data);
 
   g_main_loop_run (data.loop);